package cn.mjnxin.iot.base.domain;

/**
 * 协议类型描述
 * @author CLG 2023年10月10日
 * @version V1.0.0
 */
public class ProtocolConfig {
    /**
     * 标题
     */
    private String  title;
    /**
     * 是否作为client连Terminal，默认关闭
     */
    private boolean workAsClient = false;
	private String  address; //Terminal的IP地址
    
	private int     pid; //报文协议编号 [0,255]共256种协议
	private boolean isBigEndian;//大小端
	private int     martchMode;// 识别模式 1 起始识别串+长度 2 相同起止识别串  3 不同起止识别串
	private String  beginMatchHexVal;//起始识别串
	private String  endMatchHexVal;//末尾识别串
	private int     lengthFieldOffset = 0;//包括beginHexVal在内长度域的偏移量(lengthFieldOffset不得小于beginHexVal字节数)
	private int     lengthFieldLength = 0;//长度域本身占位长度
	private boolean isLengthIncludeLengthFieldLength;//长度域长度值是否包含长度域本身长度(0=false)
	private boolean isLengthIncludeOffsetLength;//长度域长度值是否包含偏移量本身长度(0=false)
	private int     extraDataLength = 0;//从长度字段到数据域之间非长度字段长度(寻址略过)
	private int     endExtraDataLength = 0;//数据域之后末尾非长度字段长度(不包含endMatchHexVal长度)
	private int     protocolPort;//协议对应端口号
	private int     heartbeat;//心跳周期，单位秒
	private String  autoHeartbeatPacket;//心跳包
	// 日志等级 0：无日志 1：报文长度日志 2：报文内容日志 3：所有日志
	private Integer logLevel;

	private TerminalCoder coder;

	private TerminalRepacker repacker;
	
	public ProtocolConfig(int pid) {
		this.pid = pid;
	}
	
	public int getPid() {
		return pid;
	}

	public boolean isBigEndian() {
		return isBigEndian;
	}

	public void setBigEndian(boolean isBigEndian) {
		this.isBigEndian = isBigEndian;
	}

	public String getBeginMatchHexVal() {
		return beginMatchHexVal;
	}

	public void setBeginMatchHexVal(String beginMatchHexVal) {
		this.beginMatchHexVal = beginMatchHexVal;
	}

	public int getLengthFieldOffset() {
		return lengthFieldOffset;
	}

	public void setLengthFieldOffset(int lengthFieldOffset) {
		this.lengthFieldOffset = lengthFieldOffset;
	}

	public int getLengthFieldLength() {
		return lengthFieldLength;
	}

	public void setLengthFieldLength(int lengthFieldLength) {
		this.lengthFieldLength = lengthFieldLength;
	}

	public boolean isLengthIncludeLengthFieldLength() {
		return isLengthIncludeLengthFieldLength;
	}

	public void setLengthIncludeLengthFieldLength(boolean isLenthIncludeLengthFieldLength) {
		this.isLengthIncludeLengthFieldLength = isLenthIncludeLengthFieldLength;
	}

	public int getHeartbeat() {
		return heartbeat;
	}

	public void setHeartbeat(int heartbeat) {
		this.heartbeat = heartbeat;
	}

	public int getProtocolPort() {
		return protocolPort;
	}

	public void setProtocolPort(int protocolPort) {
		this.protocolPort = protocolPort;
	}

	/**
	 * @return the isLengthIncludeOffsetLength
	 */
	public boolean isLengthIncludeOffsetLength() {
		return isLengthIncludeOffsetLength;
	}

	/**
	 * @param isLengthIncludeOffsetLength the isLengthIncludeOffsetLength to set
	 */
	public void setLengthIncludeOffsetLength(boolean isLengthIncludeOffsetLength) {
		this.isLengthIncludeOffsetLength = isLengthIncludeOffsetLength;
	}

	public int getMatchMode() {
		return martchMode;
	}

	public void setMatchMode(int martchMode) {
		this.martchMode = martchMode;
	}

	/**
	 * @return the endMatchHexVal
	 */
	public String getEndMatchHexVal() {
		return endMatchHexVal;
	}

	/**
	 * @param endMatchHexVal the endMatchHexVal to set
	 */
	public void setEndMatchHexVal(String endMatchHexVal) {
		this.endMatchHexVal = endMatchHexVal;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	public int getExtraDataLength() {
		return extraDataLength;
	}

	public void setExtraDataLength(int extraDataLength) {
		this.extraDataLength = extraDataLength;
	}

	public int getEndExtraDataLength() {
		return endExtraDataLength;
	}

	public void setEndExtraDataLength(int endExtraDataLength) {
		this.endExtraDataLength = endExtraDataLength;
	}

	public boolean isWorkAsClient() {
		return workAsClient;
	}

	public void setWorkAsClient(boolean workAsClient) {
		this.workAsClient = workAsClient;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getAutoHeartbeatPacket() {
		return autoHeartbeatPacket;
	}

	public void setAutoHeartbeatPacket(String autoHeartbeatPacket) {
		this.autoHeartbeatPacket = autoHeartbeatPacket;
	}

	public TerminalRepacker getTerminalRepacker() {
		return repacker;
	}

	public void setTerminalRepacker(TerminalRepacker repacker) {
		this.repacker = repacker;
	}

	public TerminalCoder getTerminalCoder() {
		return coder;
	}

	public void setTerminalCoder(TerminalCoder coder) {
		this.coder = coder;
	}

	public Integer getLogLevel() {
		return logLevel;
	}

	public void setLogLevel(Integer logLevel) {
		this.logLevel = logLevel;
	}
}
